package design.mode.effective_java.chapter4.item20;

import java.util.AbstractList;
import java.util.List;
import java.util.Objects;

/**
 * @author ZhongMingde on 2021/8/14
 */

public class Song {

    static List<Integer> intArrayAsList(int[] a){
        Objects.requireNonNull(a);
        return new AbstractList<Integer>() {
            @Override
            public Integer get(int index) {
                return a[index];
            }

            @Override
            public int size() {
                return 0;
            }

            @Override
            public Integer set(int i ,Integer val){
                int oldVal = a[i];
                a[i] =  val;
                return oldVal;
            }
        };
    }
}
